/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//		File Name		:		CAnimation.h
//
//		Author			:		Vindicated Games
//
//		Purpose			:		A header for all functions and members of the Animation class
//
//		Dates			:		Written( Feb 24, 2011 ) by Vindicated Games		LastUpdate( Feb 24, 2011  ) by Vindicated Games 
//	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef CANIAMTION_H_
#define CANIAMTION_H_
#include <vector>
#include <windows.h>
using std::vector;
#include <stdio.h>
#include "../tinyxml/tinyxml.h"
#include "../SGD Wrappers/CSGD_TextureManager.h"
struct Frame
	{

		RECT rRender;
		RECT rCollision;
		RECT rAttack;
		POINT ptAnchor;
		float fTime;
	};
class CAnimation
{


private:
	
	vector<Frame> vFrames;
	vector<CAnimation> vAnimation;
	int ImageID;

	float timeDelay;
	int m_nCurFrame;
	bool m_bIsPlaying;
	bool IsLooping;
	float m_fSpeed;

	
	


public:
	CAnimation();
	~CAnimation();

	CAnimation& operator=(const CAnimation& copy);

	//bool Load( const char* AnimInfo, bool looping, float delay);
	void Update( float fElapsedTime);
	void Render( float PosX, float PosY, bool IsFlipped = false, float scale = 1, DWORD color = 0xffffffff);
	void Play();
	void Stop();
	void Resume();
	bool Load(const char* AnimInfo);

	//Accessors
	int	  GetImageID() {return ImageID;}
	float GetTimeDelay() { return timeDelay;}
	int	  GetCurFrame()	 { return m_nCurFrame;}
	Frame GetFrame(int index) { return vFrames[index]; } 
	bool  Playing() { return m_bIsPlaying;}
	bool  Looping() { return IsLooping;}
	float GetSpeed()	 { return m_fSpeed;}

	RECT GetAttackFrame() { return vFrames[m_nCurFrame].rAttack; }
	RECT GetHealthFrame() { return vFrames[m_nCurFrame].rCollision; }
	RECT GetRenderFrame() { return vFrames[m_nCurFrame].rRender; }
	POINT GetAnchor() { return vFrames[m_nCurFrame].ptAnchor; }

	//Mutators
	void SetImageID(int id)		   { ImageID = id; } 
	void SetTimeDelay(float delay) { timeDelay = delay; }
	void SetCurFrame(int cur)	   { m_nCurFrame = cur; }	
	void SetIsPlaying(bool p)	   { m_bIsPlaying = p;  }
	void SetIsLooping(bool L)	   { IsLooping = L;		}
	void SetSpeed(float s)		   { m_fSpeed = s;		}

	void addFrame(Frame f)
	{
		vFrames.push_back(f);
	}
	int GetMaxFrames() { return vFrames.size(); }
	void Reset();
	
};
#endif